package fr.upmc.ta.android;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.LinearLayout;

public class MTouchGraphActivity extends Activity {

	/* une circle */
	private VCircle canva;
	/* la vue */
	private LinearLayout view;
	private static String LOG = "MTouchGraphActivity";

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		Log.i(LOG, "fr.upmc.ta.android#OnCreate");

		view = (LinearLayout) findViewById(R.id.view1);

		view.setOnTouchListener(new OnTouchListener() {
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				int action = event.getAction();

				switch (action) {

				case MotionEvent.ACTION_DOWN:
					Log.i(LOG, "fr.upmc.ta.android#onCreate#Down Action");
					canva.addPoint(new Point(event.getX(), event.getY(),
							Color.BLUE));
					break;

				case MotionEvent.ACTION_MOVE:
					Log.i(LOG, "fr.upmc.ta.android#onCreate#Move Action");
					canva.setPoint(new Point(event.getX(), event.getY(),
							Color.WHITE));
					break;
				}
				return false;
			}
		});
		canva = new VCircle(this);
		view.addView(canva);
	}
}